<?php
class KomaSystemLogin extends KomaBlock
{
    function main()
    {
        global $komaUserHandler;
        
        if (!$komaUserHandler->isUser())
        {
            $validator = array(new KomaRequiredFieldValidator(''), new KomaMinLengthValidator(3, ''));
            
            $this->Title = T_('System Login');
            $this->Template->File = 'login.html';
            $this->Template->assign('usernameCaption', T_('Username'));
            $this->Template->assign('username', new KomaWidgetText('uname', KomaCookie::getInstance()->get('uname'), null, $validator, array('size' => '15')));
            $this->Template->assign('passwordCaption', T_('Password'));
            $this->Template->assign('password', new KomaWidgetPassword('pass', null, $validator, array('size' => '15')));
            $this->Template->assign('remember', new KomaWidgetCheckbox('remember', KomaCookie::getInstance()->get('remember'), KomaCookie::getInstance()->get('remember'), T_('Remember Me')));
            $this->Template->assign('redirect', new KomaWidgetHidden('redirect', 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']));
            $this->Template->assign('submit', new KomaWidgetButton('submit', T_('Login'), KOMA_BUTTON_SUBMIT));
            
            KomaValidatorManager::getInstance()->addValidate('login');
            
            return true;
        }
        
        return false;
    }
}
?>
